<!DOCTYPE html>
<html>

<head>
    <title>回答</title>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="/js/plugins/bootstrap-4.1.1-dist/css/bootstrap.min.css">
    <script src="/js/plugins/jquery/jquery.min.js"></script>
    <script src="/js/plugins/bootstrap-4.1.1-dist/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="/css/font/css/font-awesome.min.css"/>
    <link rel="stylesheet" href="/css/reset.css"/>
    <link rel="stylesheet" href="/css/editTravels.css"/>
    <script src="/js/plugins/jrender/jrender.min.js"></script>
    <link rel="stylesheet" href="/js/plugins/dialog2/dialog.css"/>
    <link rel="stylesheet" href="/js/plugins/eleditor/layout/base.css"/>
    <script src="/js/plugins/dialog2/dialog.min.js"></script>
    <script src="/js/plugins/form/jquery.form.js"></script>
    <script src="/js/plugins/My97DatePicker/WdatePicker.js"></script>
    <script src="/js/common.js"></script>
    <!-- 插件核心-->
    <script src="/js/plugins/eleditor/Eleditor.min.js"></script>
    <!-- 如果需要图片上传 -->
    <script src="/js/plugins/eleditor/webuploader.min.js"></script>
    <style type="text/css">
        .q-detail {
            padding: .5333333333rem .5333333333rem .5333333333rem .8rem;
            box-shadow: 0 0.0533333333rem 0.32rem 0 rgba(0, 0, 0, 0.08);
            position: relative;
        }
    </style>
    <script>
        $(function () {
            var params = getParams();
            if (params.questionId) {
                $.get("/questions/" + params.questionId, function (data) {
                    $('.q-detail').renderValues(data, {
                        'getAddress': function (item, value) {
                            var add = $(item).data('href');
                            $(item).attr('href', add + value);
                        }
                    });
                });
                $('#save').click(function () {
                    $.post("/answers",{content:Edr.getContent(),questionId:params.questionId},function (data) {
                        if (data.success){
                            $(document).dialog({
                                type: 'notice',
                                infoText: '回答成功',
                                autoClose: 1000,
                                position: 'center'  // center: 居中; bottom: 底部
                            });
                            setTimeout(function () {
                                window.history.go(-1);
                            }, 1000);
                        } else {
                            $(document).dialog({
                                type: 'notice',
                                infoText: '网络出问题,请稍候重试',
                                autoClose: 1000,
                                position: 'center'  // center: 居中; bottom: 底部
                            });
                        }
                    })
                });
            }
            /*实例化一个编辑器*/
            var Edr = new Eleditor({
                el: '#contentEditor',
                upload: {
                    server: '/images'
                }
            });
        })
    </script>
</head>
<body>
<div class="search-head">
    <div class="row nav-search">
        <div class="col">
            <a href="javascript:window.history.go(-1);">
                <span><i class="fa fa-times"></i></span>
            </a>
        </div>
        <div class="col">
        </div>
        <div class="col" style="text-align: right;">
            <i class="fa fa-check" id="save"><span>发表</span></i>
        </div>
    </div>
</div>
<hr/>
<hr/>
<hr/>
<div class="container no-padding">
    <div class="q-detail">
        <h3 class="title" render-html="title"></h3>
        <p class="desc" render-html="content"></p>
        <div class="stat">
            <span class="nums"><b id="pvCount">24</b>浏览 · <b
            >4</b>回答 · <b>1275</b>评论</span>

        </div>
        <div class="meta">
            <span class="user">
                <a data-href="/userProfiles.html?id=" render-key="user.id" render-fun="getAddress">
                    <div style="text-align: right;font-size: .32rem">
                       <img render-src="user.headImgUrl" style="height:33px" class="rounded-circle">
                       <span render-html="user.nickName"></span> 于
                    <span class="time" render-html="createTime"></span>
                    </div>

                 </a>
            </span>
        </div>
    </div>
    <hr/>
    <h6 href="#" style="text-align: right">点击文章内容即可编辑</h6>
    <div id="contentEditor" class="q-detail">
    </div>
</div>
</body>

</html>